package com.weiaibenpao.demo.chislim.presenter;

import com.weiaibenpao.demo.chislim.base.BasePresenter;
import com.weiaibenpao.demo.chislim.bean.FansAttentionListBean;
import com.weiaibenpao.demo.chislim.retrofit.RetrofitUtils;
import com.weiaibenpao.demo.chislim.retrofit.rx.LoadingTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.NetWorkTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.SimpleObserver;
import com.weiaibenpao.demo.chislim.utils.Constant;
import com.weiaibenpao.demo.chislim.view.FansView;

/**
 * Created by wlx on 2018/1/15.
 */

public class FansPresenter extends BasePresenter<FansView> {
    /**
     * GET/fans/getAttentionList  关注列表分页接口
     */
    public void getAttentionList(int userId,int page) {
        RetrofitUtils.getAPIService().getAttentionList(userId, page, Constant.DEFAULT_PAGE_SIZE).
                compose(new NetWorkTransformer<FansAttentionListBean>()).
                compose(new LoadingTransformer<FansAttentionListBean>(mContext)).
                subscribe(new SimpleObserver<FansAttentionListBean>(mCompositeDisposable) {
                    @Override
                    public void call(FansAttentionListBean userBean) {
                        getView().upAttentionListSuccess(userBean);
                    }


                });
    }
    /**
     * get/fans/getFansList
     粉丝列表分页接口
     */
    public void getFansList(int userId,int page) {
        RetrofitUtils.getAPIService().getFansList(userId,page, Constant.DEFAULT_PAGE_SIZE).
                compose(new NetWorkTransformer<FansAttentionListBean>()).
                compose(new LoadingTransformer<FansAttentionListBean>(mContext)).
                subscribe(new SimpleObserver<FansAttentionListBean>(mCompositeDisposable) {
                    @Override
                    public void call(FansAttentionListBean userBean) {
                        getView().upAttentionListSuccess(userBean);
                    }

                    @Override
                    public void showErrorMsg(String message) {
                        super.showErrorMsg(message);
                        getView().onFail();
                    }
                });
    }
}
